# -*- coding:utf-8 -*-
from module_page.base_page import BaseUserPage


class UserLoginPage(BaseUserPage):
    def __init__(self):
        super().__init__()
        self.get(self.user_base_url + '/login')

    # def send_keys_username(self, username):
    #     self.send_keys('用户名输入框', username)
    #
    # def send_keys_password(self, password):
    #     self.send_keys('密码输入框', password)
    #
    # def click_loginbtn(self):
    #     self.click('登录按钮')

    def user_login_input(self, username, password):
        self.send_keys('用户名输入框', username)
        self.send_keys('密码输入框', password)
        self.click('登录按钮')

    def login_expired(self, username, password):
        if self.driver.page_contains('会话过期，请重新登录') == True:
            ele_info = self.page_eles['确定重新登录']
            self.driver.click(ele_info)
            self.user_login_input(username, password)
